package com.smallrig.mall.template.mychain;

import com.smallrig.extension.anno.Extension;
import com.smallrig.extension.chain.Context;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Service;

@Extension(bizId = "info")
@Service
@Order(1)
public class OrderInfoCommand implements OrderChain {

    @Override
    public void preHandler(Context context) {
        System.out.println("OrderInfoCommand#preHandler,context="+context);
    }

    @Override
    public void postHandler(Context context) {
        System.out.println("OrderInfoCommand#postHandler,context="+context);
    }

    @Override
    public boolean execute(Context context)  {
        OrderCtx orderContext = (OrderCtx) context;
        System.out.println("组装订单信息"+orderContext+" thread="+Thread.currentThread().getName());
        ((OrderCtx) context).setOrderId(100L);
        return false;
        //return true则break，不会执行下一个命令
    }


}
